package utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author yuh
 * @date 2018/5/3 11:18
 * @description
 */
public class RegexPatternUtil {

    private RegexPatternUtil() {
    }

    public static <T> List<T> getAllMatches(CharSequence originalStr, String regex, int group, Class<T> clazz) {
        List<Object> list = new ArrayList<>();
        Matcher matcher = Pattern.compile(regex).matcher(originalStr);
        while (matcher.find()) {
            list.add(matcher.group(group));
        }
        return (List<T>) list;
    }
}
